<?php 
//Load variables
include_once '../classes/subject.php';

$subject_code = $_GET['subject_code'];
if ($_GET['update']) $subject_code = $_GET['sub_code'];

$details = Subject::getSubjectDetails($subject_code);
$ds = Subject::getDefaultSupervisors($subject_code);
$cs = Subject::getAllocatedSupervisors($subject_code);

if ($details['sub_available'] == 1) $is_checked = "checked=\"checked\"";

$sub_supervisors = "";

foreach ($cs as $sup) {
	$sub_supervisors = $sub_supervisors . ' | ' . $sup;
}
$sub_supervisors = $sub_supervisors . ' | ';

foreach ($ds as $sup) {
	$sub_default_supervisors = $sub_default_supervisors . ' | ' . $sup;
}
$sub_default_supervisors = $sub_default_supervisors . ' | ';

?>

<?php include 'header.page.php'; ?>

	<!--Side body starts here, it contains the stuff that change from page to page.-->
    <div class="site_body">
 		<!-- This is the begining of the left column, it will contain controls -->
        <div class="left_col">
        
        <form action="index.php" method="get">
        
          <table width="450" border="0" style="margin:25px auto 0px auto;">
            <tr>
              <td width="29%" height="44" align="right">Subject Code :</td>
              <td width="50%" align="center" valign="middle"><label for="subject_code"></label>
              <input type="text" name="subject_code" id="subject_code" style="width:95%;" /></td>
              <td width="21%" align="left"><input type="submit" name="select" id="select" value="Submit" /></td>
            </tr>
            <tr>
            	<td colspan="3">
	                <hr style="padding:0px; margin:0px; border-color:#CCC;" />
                </td>
            </tr>
          </table>
        <table width="95%" border="0" style="margin:20px auto 0px auto;">
          <tr align="left">
            <td colspan="2"><p style="text-decoration:underline; margin:0px; padding:0px;"><strong>Basic Details</strong></p></td>
          </tr>
          <tr>
            <td width="24%" align="right">Code :</td>
            <td width="76%"><label for="sub_code"></label>
            <input name="sub_code" type="text" id="sub_code" style="width:70px;" value="<?php echo $details['sub_code']; ?>" readonly="readonly" /></td>
          </tr>
          <tr>
            <td align="right">Name :</td>
            <td><label for="sub_name"></label>
            <input name="sub_name" type="text" id="sub_name" style="width:95%;" value="<?php echo $details['sub_name']; ?>" /></td>
          </tr>
          <tr>
            <td align="right">Number of students :</td>
            <td><input name="sub_stdcount" type="text" id="sub_stdcount" style="width:70px;" value="<?php echo $details['sub_stdcount']; ?>" /></td>
          </tr>
          <tr>
            <td align="right">Supervisors :</td>
            <td><input name="sub_default_supervisors" type="text" id="sub_supervisors" style="width:95%;" value="<?php echo $sub_default_supervisors; ?>" /></td>
          </tr>
          <tr>
            <td align="right">Available :</td>
            <td><input name="sub_available" type="checkbox" id="sub_available" value="1" <?php echo $is_checked; ?> />
            Subject Available
            <label for="sub_available"></label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr align="left">
            <td colspan="2"><strong><span style="text-decoration:underline; margin:0px; padding:0px;">Exam Details</span></strong></td>
          </tr>
          <tr>
            <td align="right">Exam  Day :</td>
            <td><input name="sub_day" type="text" id="sub_day" style="width:70px;" value="<?php echo $details['sub_day']; ?>" /></td>
          </tr>
          <tr>
            <td align="right">Start Time :</td>
            <td><input name="sub_start" type="text" id="sub_start" style="width:70px;" value="<?php echo $details['sub_start']; ?>" /></td>
          </tr>
          <tr>
            <td align="right">End Time :</td>
            <td><input name="sub_end" type="text" id="sub_end" style="width:70px;" value="<?php echo $details['sub_end']; ?>" /></td>
          </tr>
          <tr>
            <td align="right">Hall Name :</td>
            <td><input name="sub_hall" type="text" id="sub_hall" style="width:150px;" value="<?php echo $details['sub_hall']; ?>" /></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr align="left">
            <td colspan="2"><strong><span style="text-decoration:underline; margin:0px; padding:0px;">Supervision</span></strong></td>
          </tr>
          <tr>
            <td colspan="2"><?php echo $sub_supervisors; ?>
            <hr style="padding:0px; margin:0px; border-color:#CCC;" /></td>
          </tr>
          <tr>
            <td colspan="2" align="center"><input name="action" type="hidden" id="action" value="subject_page" />
              <input type="submit" name="update" id="update" value="Update" />
            <input type="submit" name="delete" id="delete" value="Delete" /></td>
          </tr>
        </table>
		</form>
      	</div>
        <!-- Left column ends here -->
        
        <!-- This is the begining of the right column, it will contain the summary of the -->
        <div class="right_col">
        	<?php include 'rightcol.page.php';?>
        </div>
        <!-- Right column ends here-->
        
	</div>
    <!--Side body ends here-->
    
    <div class="footer">
    
    </div>
    
    <div style="clear:both;"></div>
</div>
<!-- End of container -->
</body>
</html>